include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-thunder
PKG_VERSION:=1.0
PKG_RELEASE:=1

include $(INCLUDE_DIR)/package.mk

define Package/luci-app-thunder
SECTION:=LuCI
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:=LuCI for Xware
DEPENDS:=+wget
PKGARCH:=all
MAINTAINER:=OpenWrt Developers Team <openwrt-devel@openwrt.org>
endef

define Package/luci-app-thunder/description
LuCI for Xware
endef

define Build/Compile
endef

define Package/luci-app-thunder/postinst
#!/bin/sh
( . /etc/uci-defaults/luci-thunder ) && rm -f /etc/uci-defaults/luci-thunder
exit 0
endef

define Package/luci-app-thunder/prerm
#!/bin/sh
/etc/init.d/thunder disable >/dev/null 2>&1
exit 0
endef

define Package/luci-app-thunder/postrm
#!/bin/sh
uci -q batch <<-EOF >/dev/null
	delete ucitrack.@thunder[-1]
	commit ucitrack
EOF
rm -f /tmp/luci-indexcache
rm -rf /tmp/luci-modulecache
exit 0
endef

define Package/luci-app-thunder/install
	$(CP) ./root/* $(1)
	$(INSTALL_DIR) $(1)/etc/init.d
	$(INSTALL_BIN) ./files/thunder.init $(1)/etc/init.d/thunder
	$(INSTALL_DIR) $(1)/etc/config
	$(INSTALL_CONF) ./files/thunder.config $(1)/etc/config/thunder
	$(INSTALL_DIR) $(1)/etc/uci-defaults
	$(INSTALL_BIN) ./files/luci-thunder.uci $(1)/etc/uci-defaults/luci-thunder
endef

$(eval $(call BuildPackage,luci-app-thunder))
